package Stack;

import java.util.Scanner;

public class Expressions{
    public static boolean isMarched(String expression){
        Stack<String> stack = new SeqStack<String>();
        char[] c = expression.toCharArray();
        for (char value : c) {
            switch (value) {
                case '(':
                    stack.push("(");
                    break;
                case '{':
                    stack.push("{");
                    break;
                case '[':
                    stack.push("[");
                    break;
                case ')':
                case ']':
                case '}':
                    if (stack.isEmpty()) return false;
                    else if (stack.pop().equals(value + "")) {
                        return false;
                    }
            }
        }
        if (stack.isEmpty()){
            return true;
        }else return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        System.out.println(isMarched(s));
    }
}
